package com.geekaca.testthread.wokr2;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

public class Test2Timer {
    public static void main(String[] args) {
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
//                System.out.println("aaa");
                Date date = new Date();
                SimpleDateFormat sdf = new SimpleDateFormat("YYYY-mm-DD HH:mm:ss");
                String formattedDate = sdf.format(date);
                System.out.println("当前时间: " + formattedDate);
            }
        }, 0,1000);
    }
}
